package com.example.a90610.face;

import android.util.Log;

import java.net.URLEncoder;

public class FaceMatch {
    public static String match(String filePath, String filePath2) {
        String url = "https://aip.baidubce.com/rest/2.0/face/v2/match";
        try {
            byte[] imgData = FileUtil.readFileByBytes(filePath);
            String imgStr = Base64Util.encode(imgData);
            String imgParam = URLEncoder.encode(imgStr, "UTF-8");

            byte[] imgData2 = FileUtil.readFileByBytes(filePath2);
            String imgStr2 = Base64Util.encode(imgData2);
            String imgParam2 = URLEncoder.encode(imgStr2, "UTF-8");
            String param = "images=" + imgParam + "," + imgParam2;
            String accessToken = AuthService.getAuth();
            String result = HttpUtil.post(url, accessToken, param);
            Log.e("FaceMatch", "result = " + result);
            return result;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
